﻿using Sustainalytics.Common.Hosting;
using Sustainalytics.WebApiHosting;

namespace Sustainalytics.Companies.Service
{
    public class CompaniesServiceApplication : ServiceApplication
    {
        public CompaniesServiceApplication() : base() {

        }

        public CompaniesServiceApplication(IBasicLogger logger) : base(logger)
        {

        }

        protected override void AddStartupServices()
        {
            RegisterService(new WebApiServiceDefinition<Startup>(HostConfig.GetHostUrl(), "companiesService"));

        }

        protected override bool HandleStartException(System.Exception e)
        {
            CompaniesSerilog.Log.ApplicationStartError(e);
            return false;
        }

        protected override bool HandleStopException(System.Exception e)
        {
            CompaniesSerilog.Log.ApplicationStopError(e);
            return false;
        }

        protected override void OnUnhandledDomainException(System.Exception e)
        {
            CompaniesSerilog.Log.ApplicationUnhandledException(e);
        }
    }
}
